﻿


import Request from '../../base/request.js?t=202511041006'
import Storage from '../../base/storage.js?t=202511041006'
import { imageBaseUrl, isImageFile, dealTime, downloadfun, getBrowserInfo,dealmark } from "../../base/utils.js?t=202511041006"

const Composition = (proxy) => {
    const data = reactive({
        textPopOpen: false,
        fillTextValue: null,
        pdfOpen: false,
        pdfurl: "",

        proxy: "",
        type: "",
        fileOpen: false,
        subform: {

        },
        mid: "",
        listInfo: {
            Title: null,
            UpdateTime: null,
            StartTime: null,
            EndTime: null,
            UserName: null,
            UserNo: null,
            UserNo: null,
            Manager: null,
            DepartmentName: null
        },
        totalAmount: 0,
        dict: {
            0: '通用表考评',
            1: '重点工作考评',
            2: '现场检查考评',
        },
        ScoreRate: 1,
        urlParams: {},
        s3Form: {
            TeamId: "",
            StartTime: "",
            EndTime: "",
            DepartmentId: "",
            Factor: "",
        },
        s4Form: {
            TeamId: "",
            StartTime: "",
            EndTime: "",
            DepartmentId: "",
            Factor: "",
        },
        checkGroup: [],
        memberGroup: [],

        cmemberGroup1: [],
        cmemberGroup2: [],
        checkFrom: {
            userName: "",
            userId: "",
            checkDate: "",
            advice: ""
        },
        previewShow: false,
        imgUrl: "",
        form: {
            plan: null,
            year: "",
            person: "",
            duty: "",
            subdept: ""

        },
        totala: 0,
        totals: 0,
        TotalScore: 0,
        ti: 0,
        i: 0,
        is: 0,
        iss: 0,
        planList: [],


        lists: [

        ],

        activeKey: [0, 1, 2],

        messageTest: "",

        formState: {
            dept: "",
            name: "",
            job: "",
            role: "",
            tel: "",
        },

        chooseFiles: [],

        deptList: [

        ],

        monthList: [
            { label: '1月', value: '1' },
            { label: '2月', value: '2' },
            { label: '3月', value: '3' },
            { label: '4月', value: '4' },
            { label: '5月', value: '5' }, 
            { label: '6月', value: '6' },
            { label: '7月', value: '7' },
            { label: '8月', value: '8' },
            { label: '9月', value: '9' },
            { label: '10月', value: '10' },
            { label: '11月', value: '11' },
            { label: '12月', value: '12' },
        ],

        pagination: {
            total: 0,
            loading: true,
            current: 1,
            pageSize: 10,
            showTotal: total => `总共 ${total} 项`,
            defaultPageSize: 10,
            // pageSizeOptions: ['5', '10', '15', '20'], // 可不设置使用默认
            showSizeChanger: true, // 是否显示pagesize选择
            showQuickJumper: false, // 是否显示跳转窗
        },

        uploadLock: false,
        memberList: [],

        chooseMember: {},

        logList:[],

        rules: {
            dept: [{ required: true, message: '请选择部门', trigger: 'change' }],
            name: [{ required: true, message: '请选择成员', trigger: 'change' }],

        },
        opType: "",
        confirmShow: false,
        delId: "",

        open: false,

        queryParams: {
            role: "",
            dept: "",
        },
        statusList: [
            { name: '组长', code: '0' },
            { name: '组员', code: '1' },

        ],


        columns: [
            {
                title: '序号',
                dataIndex: 'index',
                key: 'index',
                align: 'center',
                width: 80,
                customRender: ({ index}) => {
                    return (params.pagination.value.current - 1) * params.pagination.value.pageSize + index + 1
                },
            },
            {
                title: '应用模块',
                dataIndex: 'a',
                key: 'a',
                align: 'center',
                customRender: function ({ text, record, index, column }) {
                    let linkBtn = h(antd.Button, { type: 'link' }, () => text)


                    return linkBtn
                }


            },
            {
                title: '考评扣分',
                dataIndex: 'b',
                key: 'b',
                align: 'center',
                customRender: function ({ text, record, index, column }) {

                    let numberInput = h(antd.InputNumber, { style: 'width:140px', placeholder: "请输入考评扣分", min: 0, max: 100 }, () => text)


                    return numberInput
                }
            },
            {
                title: '扣分缘由',
                dataIndex: 'c',
                key: 'c',
                align: 'center',
                customRender: function ({ text, record, index, column }) {
                    let textArea = h(antd.Textarea, { placeholder: "请输入扣分缘由", autoSize: { minRows: 2, maxRows: 5 } }, () => text)
                    return textArea
                }
            },

        ],
        dataSource: [],
        fileList: [],
        itemRender: (data) => {

            let uid = data.file.uid
            const text = h('div', { style: 'cursor:pointer;margin-left:10px' }, data.file.name)
            const previewBtn = h('img', { style: 'cursor:pointer;margin:0 4px;', onclick: () => { methods.btnPreview(uid, 1) }, src: "../Bussiness/img/svg/preview.svg", width: 20, height: 22 }, '预览')
            const downloadBtn = h('img', { style: 'cursor:pointer;margin:0 4px;', onclick: () => { methods.btnDownLoad(uid, 1) }, src: "../Bussiness/img/svg/download.svg", width: 20, height: 22 }, '下载')
            
            var btns  = h('div', { style: "display:flex;" }, [
                isImageFile(data.file.url)? previewBtn:null,
                downloadBtn,

            ])

          return h('div', { style: 'margin-top:10px; width:100%;display:flex;justify-content:space-between' }, [
                text, btns
            ])

     

        },
    })
    let params = toRefs(data)

    const methods = {
        filterOption: (val, type) => {
            return `${type.value}`.includes(`${val || ''}`)
        },

        fillText: () => {

            params.lists.value[params.ti.value].NodeList
            [params.i.value].NodeList[params.is.value].NodeList
            [params.iss.value].ResultRemark = params.fillTextValue.value
            params.textPopOpen.value = false

        },

        modelShow: (ti, i, is, iss, text) => {
            params.ti.value = ti
            params.i.value = i
            params.is.value = is
            params.iss.value = iss
            params.fillTextValue.value = text
            params.textPopOpen.value = true
        },




        sdealTime: (val) => {
            if (val) {
                return dealTime(val, 'YYYY-MM-DD HH:mm:ss')
            } else {
                return dayjs().format('YYYY-MM-DD HH:mm:ss')
            }

        },

        GetOperateLogList: () => {

            return new Promise((resolve, rej) => {

                Request({
                    url: "/Performance/GetOperateLogList",
                    method: 'post',
                    params: {
                        FormId: params.urlParams.value.id
                    }

                }).then(res => {
                    params.logList.value = res.Data


                    //const uniqueArray = array.reduce((acc, current) => {
                    //    // 查找当前项是否已经在累加器中存在
                    //    const existingItemIndex = acc.findIndex(item => item.id === current.id);

                    //    if (existingItemIndex !== -1) {
                    //        // 如果找到相同的 id，则用当前项覆盖已存在的项
                    //        acc[existingItemIndex] = current;
                    //    } else {
                    //        // 如果没有找到相同的 id，则添加到累加器中
                    //        acc.push(current);
                    //    }

                    //    return acc;
                    //}, []);

                    resolve(1)

                })


            })

     

        },





        handleChange: (info, ee) => {
            if (!params.uploadLock.value) {


                params.uploadLock.value = true
                let formData = new FormData();
                formData.append('nfile', info.file.originFileObj)
                formData.append('uid', info.file.originFileObj.uid)
                Request({
                    url: "/download/uploadfile?Path=Performance",
                    method: 'post',
                    data: formData
                }).then(res => {
                    let item = params.lists.value[params.ti.value].NodeList
                    [params.i.value].NodeList[params.is.value].NodeList
                    [params.iss.value].ResultItemFileList.find(e => e.uid == res.Data[0].uid)
                    item.url = imageBaseUrl + res.Data[0].FilePath.split('../..')[1]
                    item.FileId = res.Data[0].FileId
                    item.FileName = res.Data[0].FileName
                    params.uploadLock.value = false
                    if (ee) {
                        methods.tChange(ee)
                    }
                })
            }




        },
        //handleChange1: (info) => {
        //    let formData = new FormData();
        //    formData.append('nfile', info.file.originFileObj)
        //    formData.append('uid', info.file.originFileObj.uid)
        //    Request({
        //        url: "/download/uploadfile?Path=Performance",
        //        method: 'post',
        //        data: formData
        //    }).then(res => {
        //        let item = params.fileList.value.find(e => e.uid == res.Data[0].uid)
        //        item.url = imageBaseUrl + res.Data[0].FilePath.split('../..')[1]
        //        item.FileId = res.Data[0].FileId
        //    })

        //},

        setVisible: (value) => {
            params.previewShow.value = value;
        },
        btnPreview: (e, type) => {
            if (type) {
                let item = params.fileList.value.find(es => es.uid == e)
                item.url = item.FilePath || item.url
                if (item.url.indexOf('.pdf') != -1) {
                    params.pdfurl.value = item.url
                    params.pdfOpen.value = true
                } else {
                    params.imgUrl.value = item.url

                    methods.setVisible(true)
                }
                return
            }

            let item = params.chooseFiles.value.find(es => es.uid == e)
            item.url = item.FilePath || item.url
            if (item.url.indexOf('.pdf') != -1) {
                params.pdfurl.value = item.url
                params.pdfOpen.value = true
            } else {
                params.imgUrl.value = item.url

                methods.setVisible(true)
            }
        },

        btnDownLoad: (e, type) => {
            if (type) {

                let item = params.fileList.value.find(es => es.uid == e)
                item.url = item.FilePath || item.url



                const { name, url } = item
                downloadfun(name, url)
                return
            }

            let item = params.chooseFiles.value.find(es => es.uid == e)
            item.url = item.FilePath || item.url

            const { name, url } = item
            downloadfun(name, url)

        },
        btnDelete: (e, type) => {
            if (type) {
                params.chooseFiles.value = params.chooseFiles.value.filter(es => es.uid != e)
                params.lists.value[params.ti.value].NodeList
                [params.i.value].NodeList[params.is.value].NodeList
                [params.iss.value].ItemFileList = params.lists.value[params.ti.value].NodeList
                [params.i.value].NodeList[params.is.value].NodeList
                [params.iss.value].ItemFileList.filter(es => es.uid != e)
                return
            }

            params.lists.value[params.ti.value].NodeList
            [params.i.value].NodeList[params.is.value].NodeList
            [params.iss.value].ResultItemFileList = params.lists.value[params.ti.value].NodeList
            [params.i.value].NodeList[params.is.value].NodeList
            [params.iss.value].ResultItemFileList.filter(es => es.uid != e)


            params.chooseFiles.value = params.chooseFiles.value.filter(es => es.uid != e)
        },



        tChange: function (e) {

            if (e.ItemId) {
                methods.UpdateEvalutionUser(e.ItemId).then(res => {
                    let info = Storage.get('AccountInfo', true)
                    e.EvalutionName = `${info.UserName}(${info.UserNo})`
                })
            } else {
                let info = Storage.get('AccountInfo', true)
                e.EvalutionName = `${info.UserName}(${info.UserNo})`
            }

        },
        planChange: (e) => {

            Request({
                url: "/Performance/GetSelfTempleteByPlan",
                method: 'post',
                params: {
                    Id: e
                }

            }).then(res => {

                params.list.value = res.Data[0].NodeList
                params.TotalScore.value = res.Data[0].TotalScore

            })
        },
        handleFile: (i, is, iss, ess) => {
            params.fileOpen.value = true
            params.i.value = i
            params.is.value = is
            params.iss.value = iss

            params.chooseFiles.value = ess.ItemFileList.map(e => {
                e.url = e.url ? e.url : imageBaseUrl + e.FilePath.split('../..')[1]
                e.FileId = e.FileId
                e.name = e.FileName
                e.isImage = isImageFile(e.url || e.FilePath)
                e.isDelete = false
                return e
            })

        },
        handleFile1: (ti, i, is, iss, ess) => {
            params.fileOpen.value = true
            params.ti.value = ti
            params.i.value = i
            params.is.value = is
            params.iss.value = iss
            params.chooseFiles.value = ess.ResultItemFileList.map(e => {
                return {
                    ...e,
                    FileId: e.FileId,
                    name: e.originFileObj ? e.name : e.FileName,
                    isImage: isImageFile(e.url || e.FilePath),
                    isDelete: false
                }
            })


        },


        iichange: (i) => {

            let list = new Set()

            if (params.lists.value[i].NodeList) {
                for (let node of params.lists.value[i].NodeList) {

                    if (node.NodeList) {

                        for (let item of node.NodeList) {

                            if (item.NodeList) {
                                for (let ii of item.NodeList) {
                                    list.add(ii.EvalutionName)
                                }
                            }


                        }
                    }

                }
            }


            params.lists.value[i].nameList = Array.from(list).filter(Boolean)

            let f = params.lists.value[i].NodeList.map((e, i) => {
                let ff = {

                }
                if (e.CalcType == 0) {
                    if (e.NodeList) {
                        let zz = e.NodeList.map(es => {
                            if (es.NodeList) {
                                let res = es.NodeList.map(ess => {
                                    return ess.ResultScore ? ess.ResultScore : 0
                                })
                                return res.reduce((prev, cur, index, arr) => {
                                    return prev + cur
                                }, 0)
                            }
                        })
                        ff.sub = zz.reduce((prev, cur, index, arr) => {
                            return prev + cur
                        }, 0)
                    }
                } else {
                    if (e.NodeList) {
                        let zz = e.NodeList.map(es => {
                            if (es.NodeList) {
                                let res = es.NodeList.map(ess => {
                                    return ess.ResultScore ? ess.ResultScore : 0
                                })
                                return res.reduce((prev, cur, index, arr) => {
                                    return prev + cur
                                }, 0)
                            }
                        })
                        ff.add = zz.reduce((prev, cur, index, arr) => {
                            return prev + cur
                        }, 0)
                    }
                }

                return ff
            })



            params.lists.value[i].totala = 0
            params.lists.value[i].totals = 0
            params.lists.value[i].TotalScore = params.lists.value[i].TotalScore



            for (let e of f) {
                if (e.add) {
                    params.lists.value[i].totala += e.add
                } else if (e.sub) { params.lists.value[i].totals += e.sub }
            }
            let total = params.lists.value.reduce((acc, item) => acc + item.TotalScore, 0);



            params.totalAmount.value = params.lists.value.reduce((acc, item) => acc + Number(methods.Idealmark(item.TotalScore - (item.totals * params.ScoreRate.value - item.totala).toFixed(2), item.TotalScore)), 0);



            params.totalAmount.value = Number(Number(params.totalAmount.value / total * 100).toFixed(2))


        },
        Idealmark: (number, mark, flag = true) => {
            return dealmark(number, flag ? mark:null)
        },
        ichange: (e, ee) => {

            if (ee) {


                methods.tChange(ee)
            }

            let f = params.lists.value[0].NodeList.map((e, i) => {
                let ff = {

                }
                if (e.CalcType == 0) {
                    if (e.NodeList) {
                        let zz = e.NodeList.map(es => {
                            if (es.NodeList) {
                                let res = es.NodeList.map(ess => {
                                    return ess.SelfScore ? ess.SelfScore : 0
                                })
                                return res.reduce((prev, cur, index, arr) => {
                                    return prev + cur
                                }, 0)
                            }
                        })
                        ff.sub = zz.reduce((prev, cur, index, arr) => {
                            return prev + cur
                        }, 0)
                    }
                } else {
                    if (e.NodeList) {
                        let zz = e.NodeList.map(es => {
                            if (es.NodeList) {
                                let res = es.NodeList.map(ess => {
                                    return ess.SelfScore ? ess.SelfScore : 0
                                })
                                return res.reduce((prev, cur, index, arr) => {
                                    return prev + cur
                                }, 0)
                            }
                        })
                        ff.add = zz.reduce((prev, cur, index, arr) => {
                            return prev + cur
                        }, 0)
                    }
                }

                return ff
            })
            let totala = 0
            let totals = 0


            params.listInfo.value.SelfTotalScore = params.lists.value[0].TotalScore


            for (let e of f) {
                if (e.add) {
                    totala += e.add
                } else if (e.sub) { totals += e.sub }
            }
            params.totala.value = totala
            params.totals.value = totals

            console.log(params.listInfo.value.SelfTotalScore + totala -totals)
            console.log(totals)
        },
        handleDrop: (e) => {
            console.log(e, 'drag');
        },

        GetDepartmentConfig: (id) => {
            return new Promise((resolve, reject) => {

                Request({
                    url: "/Performance/GetDepartmentConfig",
                    method: 'post',
                    data: {
                        DepartmentId: id
                    }

                }).then(res => {

                    resolve(1)
                    params.ScoreRate.value = res.Data.ScoreRate


                })


            })
 
        },
  
       

        getTableList: (isRresh) => {
            if (isRresh) {
                params.pagination.value.current = 1
            }
            //Request({
            //    url: "performance/GetTemplistList",
            //    method: 'post',
            //    params: {
            //        Years: 2024,
            //        TypeId: 1
            //    }
            //}).then(res => {
            //    params.list.value = res.Data[0].NodeList
            //    console.log(res, 'res')

            //})
        },
        UpdateEvalutionUser: (id) => {
            return new Promise((resolve, rej) => {
                Request({
                    url: "performance/UpdateEvalutionUser",
                    method: 'post',
                    params: {
                        ItemId: id,
                    }
                }).then(res => {
                    resolve(1)
                    console.log(res, 'res')

                })
            })

        },



        upload: (ti, i, is, iss) => {
            params.ti.value = ti
            params.i.value = i
            params.is.value = is
            params.iss.value = iss
                    
            if (!params.lists.value[params.ti.value].NodeList
            [params.i.value].NodeList[params.is.value].NodeList
            [params.iss.value].ResultItemFileList) {
                params.lists.value[params.ti.value].NodeList
                [params.i.value].NodeList[params.is.value].NodeList
                [params.iss.value].ResultItemFileList = []
            }

        },
        init: () => {
              getBrowserInfo().catch(err => { console.log(err)})
            if (proxy) {
                params.proxy.value = proxy
            }
            const { message } = antd
            params.messageTest.value = message
            params.messageTest.value.config({
                top: `10vh`,
                duration: 7,
                maxCount: 1,
                rtl: true,
            });
              getBrowserInfo().catch(err => { console.log(err)})
            function queryURLParams() {
                const searchParams = window.location.search.substring(1).split("&");
                const params = {};

                for (const param of searchParams) {
                    const [key, value] = param.split("=");
                    params[key] = value;
                }

                return params;
            }
            const { id } = queryURLParams()
            params.mid.value = id
            params.urlParams.value = queryURLParams()


            params.uploadLock.value=true

            let info = Storage.get('AccountInfo', true)
            Request({
                url: "/Account/createJwtToken",
                method: 'post',
                data: {
                    "userName": info && info.UserNo
                }
            }).then(res => {
                Storage.set('token', res.Data,true)
                methods.getTableList(true)

                Request({
                    url: "/performance/GetSelfCheckFormEvaluation", 
                    method: 'post',
                    params: {
                        FormId: id
                    }
                }).then(async res => {

                    params.listInfo.value.DepartmentName = res.Data.DepartmentName
                    params.listInfo.value.UpdateTime = dealTime(res.Data.UpdateTime, 'YYYY-MM-DD HH:mm:ss')
                    params.listInfo.value.UserName = res.Data.UserName
                    params.listInfo.value.UserNo = res.Data.UserNo

                    params.listInfo.value.EvalutionUserList = res.Data.EvalutionUserList

                    let info = Storage.get('AccountInfo', true)

                    await methods.GetOperateLogList()


                    if (params.urlParams.value.detail) {
                      
 
                        params.checkFrom.value.userName = params.logList.value[2]?params.logList.value[2].OperateList.map(e => `${e.OperateUser}`).toString():'-'

                        params.checkFrom.value.subTime = params.logList.value[2] ? params.logList.value[2].OperateList.filter(e => e.IsApprove).length == 0 ? '-' : dealTime(params.logList.value[1].OperateList.filter(e => e.IsApprove)[params.logList.value[1].OperateList.filter(e => e.IsApprove).length - 1]?.OperateTime,'YYYY-MM-DD HH:mm:ss') : '-'

                        //console.log(params.checkFrom.value.subTime, 'params.checkFrom.value.subTime')

                    } else {
                        params.checkFrom.value.userName = `${info.UserName}(${info.UserNo})`
                        params.checkFrom.value.subTime = dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss')
          
                    }
           
           
                    methods.GetDepartmentConfig(res.Data.DepartmentId).then(ress => {
                        if (ress) {
                            params.uploadLock.value = false

                            params.fileList.value = res.Data.FileList.map(e => {
                                return {
                                    ...e,
                                    name: e.FileName,
                                    url: e.url ? e.url : imageBaseUrl + e.FilePath.split('../..')[1],
                                    FileId: e.FileId
                                }
                            })



                            params.lists.value = res.Data.ItemList.map(e => {

                                return {
                                    ...e,
                                    totala: 0,
                                    totals: 0,
                                }
                            })


                            methods.ichange()
                            for (let i = 0; i < params.lists.value.length; i++) {
                                methods.iichange(i)
                            }


                        }
                    })

               

                    Request({
                        url: "/performance/GetSimplePlanList",
                        method: 'post',
                        params: {
                            Id: params.urlParams.value.id
                        }
                    }).then(res => {


                        params.checkGroup.value = res.Data.map(e => {
                            return {
                                label: e.TeamName,
                                value: e.Id,
                                list: e.MemberList
                            }
                        })


                        let item = res.Data.filter(e => e.Id == params.urlParams.value.planid)[0]

                        params.listInfo.value.StartTime = dealTime(item.StartTime, 'YYYY-MM-DD')
                        params.listInfo.value.EndTime = dealTime(item.EndTime, 'YYYY-MM-DD')
                        params.listInfo.value.PlanNoticeName = item.Title
                    })

                    Request({
                        url: "/SystemConfig/GetUserListByDepartment",
                        method: 'post',
                        params: {
                            DepartmentId: res.Data.DepartmentId
                        }
                    }).then(res => {


                        params.memberGroup.value = res.Data.map(e => {
                            return {
                                label: `${e.UserName}(${e.UserNo})`,
                                value: e.UserNo
                            }
                        })
                    })




                })





            })

            params.form.value.person = info.UserName
            params.form.value.subdept = info.DepartmentName




            let arry = ['责任', '目标', '风险', '隐患', '培训', '文化', '制度', '应急', '合规', '相关方']
            params.dataSource.value = arry.map(e => {
                return {
                    a: e,
                    b: "",
                    c: ""
                }
            })
            function queryURLParams() {
                const searchParams = window.location.search.substring(1).split("&");
                const params = {};

                for (const param of searchParams) {
                    const [key, value] = param.split("=");
                    params[key] = value;
                }

                return params;
            }
            const { type } = queryURLParams()
            params.type.value = type

        },
        groupChange: (e) => {


            let item = params.checkGroup.value.find(es => es.value == e)


            params.cmemberGroup1.value = item.list.map(e => {

                return {
                    label: `${e.MemberName}(${e.UserNo})`,

                    value: e.UserNo
                }

            })

            params.s3Form.value.Time = dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss')

            params.s3Form.value.checkMan = []

        },

        groupChange1: (e) => {

            let item = params.checkGroup.value.find(es => es.value == e)

            params.cmemberGroup2.value = item.list.map(e => {
                return {
                    label: `${e.MemberName}(${e.UserNo})`,
                    value: e.UserNo
                }
            })

            params.s4Form.value.Time = dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss')

            params.s4Form.value.checkMan = []

        },

        onSubmit: (IsApprove) => {


            let obj = {
                "FormId": params.urlParams.value.id,
                "IsApprove": IsApprove,
                "Remark": params.checkFrom.value.Remark,
                "Status": params.urlParams.value.status
            }

            Request({
                url: "/Performance/ApproveYearReport",
                method: 'post',
                data: obj

            }).then(res => {


                        params.messageTest.value.info(res.Msg);

                setTimeout(() => {
                    methods.onBack()
                }, 1500)
            })



        },
        export: (i) => {



            params.uploadLock.value = true
            html2canvas(document.querySelector(`#c${i}`)).then(async (canvas) => {




                // 将 canvas 转换为 Blob
                const blob = await new Promise((resolve, reject) => {
                    canvas.toBlob(resolve, 'image/png');
                });

                // 创建 FormData 对象
                const formData = new FormData();
                formData.append('file', blob, 'pdf.png');

                Request({
                    url: "/download/uploadfile?Path=toPdf",
                    method: 'post',
                    data: formData
                }).then(res => {




                    Request({
                        url: `/Performance/ExportPdf?FileId=${res.Data[0].FileId}`,
                        method: 'post',

                    }).then(res => {

                        let name = {
                            0:'通用部分报表',
                            1: '重点工作报表',
                            2: '现场检查报表',
                        }

                        downloadfun(name[i], res.Data)


                        params.uploadLock.value = false

                    })







                })
            });
        },
        onBack: () => {
            window.close()
            //window.location.href = '/Performance/PerformanceMeansureNew'
        }


    }
    const template = {


        pdfPopModel: {
            template: `
           <a-modal v-model:open="pdfOpen" width = "80%" title = "PDF预览" v-on:ok="pdfOpen=false" >
<div style='height:700px'>
                <embed id="pdfviewscreen" :src="pdfurl" type="application/pdf" width="100%" style="height:100%;" />

</div>
  
            </a-modal >
`,
            setup() {
                return {
                    ...params,
                    ...methods,
                };
            }
        },



        popModel: {
            template: `
        <a-modal v-model:open="textPopOpen" width="60%" title="考评情况/资料说明" ok-text="保存" v-on:ok="fillText">
                <div style="padding:30px;box-sizing:border-box">
                    <a-textarea v-model:value="fillTextValue" placeholder="考评情况/资料说明"  :auto-size="{ minRows: 16, maxRows: 25 }" />
                </div>
            </a-modal>
`,
            setup() {

                return {
                    ...params,
                    ...methods,
                };
            }
        },
        bottomBtns: {
            template: `<div class="w-full bg-[#eeeeee] h-50  flex  items-center justify-end">
                    <a-space>


  <a-popconfirm
    title="确定执行此操作?"
    ok-text="确定"
    cancel-text="取消"
    @confirm="onSubmit(false)"
  >


       <a-button :loading="uploadLock" v-if="!urlParams.detail" type="primary" danger>驳回</a-button>
  </a-popconfirm>

  <a-popconfirm
    title="确定执行此操作?"
    ok-text="确定"
    cancel-text="取消"
    @confirm="onSubmit(true)"
  >


         <a-button :loading="uploadLock" v-if="!urlParams.detail"  type="primary">通过</a-button>
  </a-popconfirm>

                 
               
                        <a-button v-on:click="onBack">返回</a-button>


                    </a-space>
                </div>`,
            setup() {

                return {
                    ...params,
                    ...methods,
                };
            }

        }
    }


    //let template = toRefs(vtemplate)
    return { // 返回对象给模板

        ...params,
        ...methods,
        template

    }
}


export default Composition